/*************************************************************************
	> File Name: P1241.cpp
	> Author: yufangze
	> Mail: 2224590123@qq.com
	> Created Time: 2025-01-09 09:54:50
 ************************************************************************/

#include <iostream>
#include <set>
#include <map>
#include <vector>
#include <algorithm>
using namespace std;

int flag[105];
int main() {
    string str;
    cin >> str;
    for (int i = 0; i < str.size(); i++) {
        if (str[i] == ')') {
            for (int j = i - 1; j >= 0; j--) {
                if (str[j] == '(' and flag[j] == 0) {
                    flag[i] = 1;
                    flag[j] = 1;
                    break;
                } else if (str[j] == '[' and flag[j] == 0) {
                    break;
                }
            }
        } else if (str[i] == ']') {
            for (int j = i - 1; j >= 0; j--) {
                if (str[j] == '[' and flag[j] == 0) {
                    flag[i] = 1;
                    flag[j] = 1;
                    break;
                } else if (str[j] == '(' and flag[j] == 0) {
                    break;
                }
            }
        }
    }
    for (int i = 0; i < str.size(); i++) {
        if (flag[i] == 0) {
            if (str[i] == '(' or str[i] == ')') {
                cout << "()";
            } else {
                cout << "[]";
            }
        } else {
            cout << str[i];
        }
    }
    cout << endl;
    return 0;
}
